﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using fcwms.Common;
using System.Web.UI.HtmlControls;


public partial class admin_chuku_chuku_list : SessionManage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RptBind();
            //RukuStorageBind();
            //RukuWayBind();
        }
    }
    #region 组合数据绑定==========================
    public void RptBind()
    {
        //string decla_id = txtDeclaID.Text.Trim();
        //string ruku_status = this.selStatus.Value;
        //string start_time = txtStartTime.Text.Trim();
        //string end_time = txtEndTime.Text.Trim();
        //string ruku_storage = this.selStorage.Value;
        //string transactor = txtTransactor.Text.Trim();
        //string ruku_way = this.selRukuWay.Value;

        StringBuilder strSql = new StringBuilder();
        strSql.Append("select * ");
        strSql.Append(" FROM dt_chuku where 1=1 ");
        //if (txtDeclaID.Text.Trim() != string.Empty)
        //{
        //    strSql.Append("and decla_id=@decla_id ");
        //}
        //if (this.selStatus.Value.Trim() != string.Empty)
        //{
        //    strSql.Append("and ruku_status=@ruku_status ");
        //}
        //if (txtStartTime.Text.Trim() != string.Empty && txtEndTime.Text.Trim() != string.Empty)
        //{
        //    strSql.Append("and ruku_time between @start_time and @end_time ");
        //}
        //if (this.selStorage.Value != string.Empty)
        //{
        //    strSql.Append("and ruku_storage=@ruku_storage ");
        //}
        //if (txtTransactor.Text.Trim() != string.Empty)
        //{
        //    strSql.Append("and transactor=@transactor ");
        //}
        //if (this.selRukuWay.Value != string.Empty)
        //{
        //    strSql.Append("and ruku_way=@ruku_way ");
        //}
        //strSql.Append("order by id desc");

        //SqlParameter[] parms = new SqlParameter[] { 
        //    new SqlParameter("@decla_id",decla_id),
        //    new SqlParameter("@ruku_status",ruku_status),
        //    new SqlParameter("@start_time",start_time),
        //    new SqlParameter("@end_time",end_time),
        //    new SqlParameter("@ruku_storage",ruku_storage),
        //    new SqlParameter("@transactor",transactor),
        //    new SqlParameter("@ruku_way",ruku_way)};
        DataSet ds = DbHelperSQL.Query(strSql.ToString());

        this.AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;  //DataView的Count属性,AspNetPager的RecordCount属性.
        PagedDataSource pds = new PagedDataSource();
        pds.AllowPaging = true;                                   //启用分页.
        pds.PageSize = AspNetPager1.PageSize;                     //每页要显示的记录条数.      
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; //当前页索引.
        pds.DataSource = ds.Tables[0].DefaultView;                //分页数据源以DataView为数据源.  
        lblCount.Text = AspNetPager1.RecordCount.ToString();      //总共几条数据
        rptList.DataSource = pds;
        rptList.DataBind();
    }
   
    #endregion

    //每页记录数选择
    protected void btn10_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 10;
        RptBind();
    }
    protected void btn20_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 20;
        RptBind();
    }
    protected void btn50_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 50;
        RptBind();
    }
    //分页绑定
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        RptBind();
    }
    #region 删除操作==============================
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        ////ChkAdminLevel("sys_branch", ActionEnum.Delete.ToString()); //检查权限
        fcwms.BLL.dt_chuku bll = new fcwms.BLL.dt_chuku();
        for (int i = 0; i < rptList.Items.Count; i++)
        {
            int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
            CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
            if (cb.Checked)
            {
                bll.Delete(id);
            }
        }
        MessageBox.Jscript(this, "批量删除成功啦", "chuku_list.aspx", "Success");
    }
    #endregion
}